package com.apes.fico.finance.model.costcollect;


import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = TypeCost.CONST_TABLE_NAME)
public class TypeCost extends Model {
    public final static String CONST_TABLE_NAME = "gl_type_cost";

    @Id
    @Column(name="id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "成本类别", padding = 8)
    @Comment("成本类别编码")
    private String id; // 收入类型编码

    @Column(name = "name", nullable = false)
    @Comment("成本类别型名称")
    private String name; // 收入类型名称

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "in_come_category", referencedColumnName = "id")
    @Comment("成本类别")
    private Enumeration inComeCategory; // 收入类别（rebate：返利；cost：费用；margin：保证金；miscellaneousIncome：杂项收入）

    @Column(name = "valid", nullable = false, columnDefinition = "number(1, 0) default 1")
    @Comment("有效标记")
    private boolean valid; // 有效标记

}
